// 钩子函数示例 hooks/index.js

function beforeRegister({
  userRecord
} = {}) {
	
	if(!userRecord.nickname) {
	  userRecord.nickname = "匿名" + Math.random().toString(36).substring(3, 9)
	}
	if(userRecord.role) {
	  userRecord.role.push('user')
	} else {
	  userRecord.role = ['user']
	}
	if(!userRecord.avatar_file) {
		userRecord.avatar_file = "https://mp-ed001371-7a92-4df0-8911-b5b051b5c39e.cdn.bspapp.com/cloudstorage/8ec9b843-76b4-4374-9770-fbf36af4f88d.jpg"
	}
	
  return userRecord // 务必返回处理后的userRecord
}

module.exports = {
  beforeRegister
}
